package com.wd.tw.websocket.helper;

import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class CallbackDecodeHelper {

    public static List decodeArray(String message){
        if(JSONUtil.isJson(message)){
            CallbackDto callbackDto =  JSONUtil.toBean(message,CallbackDto.class);
            if(callbackDto.getCode() == 200){
                return callbackDto.getArray();
            }
        }
        return null;
    }

    public static Object decode(String message){
        if(JSONUtil.isJson(message)){
            CallbackDto callbackDto =  JSONUtil.toBean(message,CallbackDto.class);
            if(callbackDto.getCode() == 200){
                return callbackDto.getObj();
            }else{
                log.error("访问honsvr异常,{}",message);
            }
        }
        return null;
    }
}
